<?php
/*code here*/
/* Redirect user if they already logged */
if(Auth::hasAuth('current_user'))
{
    $this->view->current_user = Auth::getAuth('current_user');

    header('location: /');
}
/* For user login if correct redirect to home */
if($_SERVER['REQUEST_METHOD'] == "POST")
{
    
    
    $username = $_POST['username'];
    $password = $_POST['password'];
    $session = new Auth();
    $login = $session->login($username,$password,'email','password','tbuser');
    if($login)
    {
        if(isset($_GET['redirect_url'])){
            $decode_url = Functions::encode_decode_url($_GET['redirect_url'],"decode");
            header('Location: /' . $decode_url); 
        }else{
            header('Location: /'); 
        }
    }
}   
/*code here(end)*/
$this->setLayout();